<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2007 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version
**********************************************/
if (!defined('INSTALL')) { exit; }

$upgrade_failed = "<br /><br />Please contact the CPG-Nuke Dev Team about the error<br />You cannot continue with the installation";
		echo '<h3>'.$instlang['s3_sync_data'].':</h3>';

if (version_compare($version, '9.3.2.2', '<')) {
	exit('Upgrade needs atleast v9.3.2.2');
}

if (version_compare($version, '10.0.9.33', '<')) {
	$db->delete('security_agents', 'agent_name LIKE "Google%"');
	$db->delete('security_agents', 'agent_name LIKE "Yahoo%"');
	$db->delete('security_agents', 'agent_name LIKE "Yandex%"');
}

if (version_compare($version, '10.0.9.41', '<')) {
	foreach (Client::$browserlang as $new => $old) {
		$db->query("UPDATE {$prefix}_blocks SET blanguage='{$new}' WHERE blanguage='{$old}'");
		$db->query("UPDATE {$prefix}_history SET language='{$new}' WHERE language='{$old}'");
		$db->query("UPDATE {$prefix}_message SET mlanguage='{$new}' WHERE mlanguage='{$old}'");
		$db->query("UPDATE {$user_prefix}_users SET user_lang='{$new}' WHERE user_lang='{$old}'");
		$db->query("UPDATE {$user_prefix}_users_temp SET user_lang='{$new}' WHERE user_lang='{$old}'");
	}

	list($oldlng) = $db->uFetchRow("SELECT cfg_value FROM {$prefix}_config_custom WHERE cfg_name='global' AND cfg_field='language'");
	if ($newlng = array_search($oldlng,Client::$browserlang)) {
		$db->query("UPDATE {$prefix}_config_custom SET cfg_value='{$newlng}' WHERE cfg_name='global' AND cfg_field='language'");
	}
}
